# 测试认证服务注册接口
$uri = "http://localhost:8084/api/auth/register"
$body = @{
    username = "testuser3"
    password = "testpass123"
    email = "test3@example.com"
} | ConvertTo-Json

Write-Host "测试注册接口: $uri"
Write-Host "请求体: $body"

try {
    $response = Invoke-RestMethod -Uri $uri -Method Post -Body $body -ContentType "application/json" -ErrorAction Stop
    Write-Host "注册成功!" -ForegroundColor Green
    Write-Host "响应: $($response | ConvertTo-Json -Depth 10)"
} catch {
    Write-Host "错误: $($_.Exception.Message)" -ForegroundColor Red
    if ($_.Exception.Response) {
        $statusCode = $_.Exception.Response.StatusCode
        $statusDescription = $_.Exception.Response.StatusDescription
        Write-Host "状态码: $statusCode" -ForegroundColor Red
        Write-Host "状态描述: $statusDescription" -ForegroundColor Red
        
        # 尝试读取响应内容
        $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
        $errorResponse = $reader.ReadToEnd()
        $reader.Close()
        Write-Host "错误响应: $errorResponse" -ForegroundColor Red
    }
}